using System;
using UnityEngine;
using UnityEngine.UI;

public class ProjectSet : MonoBehaviour
{
    /// <summary>
    /// 项目名称输入框
    /// </summary>
    private InputField input_name;
    /// <summary>
    /// 保存项目按钮
    /// </summary>
    private Button btn_save;
    /// <summary>
    /// 删除项目按钮
    /// </summary>
    private Button btn_delete;

    protected void Awake()
    {
        input_name = transform.Find("input_name").GetComponent<InputField>();
        btn_save = transform.Find("btn_save").GetComponent<Button>();
        btn_delete = transform.Find("btn_delete").GetComponent<Button>();

        btn_save.onClick.AddListener(OnSaveClick);
        btn_delete.onClick.AddListener(OnDeleteClick);
    }

    public void OnSaveClick()
    {
        if (!String.IsNullOrEmpty(input_name.text)) ExcelTool.GetInstance().SaveData();
    }

    public void OnDeleteClick()
    {
        if (!String.IsNullOrEmpty(input_name.text)) ExcelTool.GetInstance().DeleteData();
    }



    /// <summary>
    /// 设置项目名称
    /// </summary>
    public void SetName(string name)
    {
        input_name.text = name;
    }

    /// <summary>
    /// 获取项目名称
    /// </summary>
    public string GetName()
    {
        return input_name.text;
    }
}
